package com.garlicts.framework.binlog.sync.canal;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class CanalApplicatoinContextAware implements ApplicationContextAware,InitializingBean {
	
	ApplicationContext applicationContext;
	CanalSyncHandler canalSyncHandler;
	
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
		this.canalSyncHandler = applicationContext.getBean(CanalSyncHandler.class);
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		canalSyncHandler.execute(applicationContext);
	}

}
